import java.util.Locale;
import java.util.Scanner;

/**
 * Created with Intellij IDEA
 * Description
 * User:ASUS
 * Date:2024-08-06
 * Time:17:05
 */
public class Test {
    public static boolean isValidChar(char ch){
        if ((ch>='a'&&ch<='z')||(ch>='0'&&ch<='9')){
            return true;
        }
        return false;
    }
    public boolean isPalindrome(String s){
        //将大小写统一起来
        s=s.toLowerCase(Locale.ROOT);
        int left=0;
        int right=s.length()-1;
        while(left<right){
            //从左侧找一个有效的字符
            while(left<right&&!isValidChar(s.charAt(left))){
                left++;
            }
            //从右侧找一个有效的字符
            while(left<right&&!isValidChar(s.charAt(right))){
                right++;
            }
            if (s.charAt(left)!=s.charAt(right)){
                return false;
            }else{
                left++;
                right--;
            }
        }
        return true;
    }
}
